<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/gui/widgets/qgroupbox.cpp -->
<head>
  <title>Qt 4.3: QGroupBox Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QGroupBox Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1>
<p>The QGroupBox widget provides a group box frame with a title. <a href="#details">More...</a></p>
<pre> #include &lt;QGroupBox&gt;</pre><p>Inherits <a href="qwidget.html">QWidget</a>.</p>
<p>Inherited by <a href="q3groupbox.html">Q3GroupBox</a>.</p>
<ul>
<li><a href="qgroupbox-members.html">List of all members, including inherited members</a></li>
<li><a href="qgroupbox-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="properties"></a>
<h3>Properties</h3>
<p><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="45%" valign="top"><ul>
<li><div class="fn"/><b><a href="qgroupbox.html#alignment-prop">alignment</a></b> : Qt::Alignment</li>
<li><div class="fn"/><b><a href="qgroupbox.html#checkable-prop">checkable</a></b> : bool</li>
<li><div class="fn"/><b><a href="qgroupbox.html#checked-prop">checked</a></b> : bool</li>
</ul></td><td valign="top"><ul>
<li><div class="fn"/><b><a href="qgroupbox.html#flat-prop">flat</a></b> : bool</li>
<li><div class="fn"/><b><a href="qgroupbox.html#title-prop">title</a></b> : QString</li>
</ul>
</td></tr>
</table></p>
<ul>
<li><div class="fn"/>56 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qgroupbox.html#QGroupBox">QGroupBox</a></b> ( QWidget * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qgroupbox.html#QGroupBox-2">QGroupBox</a></b> ( const QString &amp; <i>title</i>, QWidget * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qgroupbox.html#dtor.QGroupBox">~QGroupBox</a></b> ()</li>
<li><div class="fn"/>Qt::Alignment <b><a href="qgroupbox.html#alignment-prop">alignment</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qgroupbox.html#checkable-prop">isCheckable</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qgroupbox.html#checked-prop">isChecked</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qgroupbox.html#flat-prop">isFlat</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qgroupbox.html#alignment-prop">setAlignment</a></b> ( int <i>alignment</i> )</li>
<li><div class="fn"/>void <b><a href="qgroupbox.html#checkable-prop">setCheckable</a></b> ( bool <i>checkable</i> )</li>
<li><div class="fn"/>void <b><a href="qgroupbox.html#flat-prop">setFlat</a></b> ( bool <i>flat</i> )</li>
<li><div class="fn"/>void <b><a href="qgroupbox.html#title-prop">setTitle</a></b> ( const QString &amp; <i>title</i> )</li>
<li><div class="fn"/>QString <b><a href="qgroupbox.html#title-prop">title</a></b> () const</li>
</ul>
<ul>
<li><div class="fn"/>201 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li><div class="fn"/>12 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"/>void <b><a href="qgroupbox.html#checked-prop">setChecked</a></b> ( bool <i>checked</i> )</li>
</ul>
<ul>
<li><div class="fn"/>19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="qgroupbox.html#clicked">clicked</a></b> ( bool <i>checked</i> = false )</li>
<li><div class="fn"/>void <b><a href="qgroupbox.html#toggled">toggled</a></b> ( bool <i>on</i> )</li>
</ul>
<ul>
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h3>Protected Functions</h3>
<ul>
<li><div class="fn"/>void <b><a href="qgroupbox.html#initStyleOption">initStyleOption</a></b> ( QStyleOptionGroupBox * <i>option</i> ) const</li>
</ul>
<ul>
<li><div class="fn"/>38 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"/>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"/>1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QGroupBox widget provides a group box frame with a title.</p>
<p>A group box provides a frame, a title and a keyboard shortcut, and displays various other widgets inside itself. The title is on top, the keyboard shortcut moves keyboard focus to one of the group box's child widgets.</p>
<p>QGroupBox also lets you set the <a href="qgroupbox.html#title-prop">title</a> (normally set in the constructor) and the title's <a href="qgroupbox.html#alignment-prop">alignment</a>. Group boxes can be <a href="qgroupbox.html#checkable-prop">checkable</a>; child widgets in checkable group boxes are enabled or disabled depending on whether or not the group box is <a href="qgroupbox.html#checked-prop">checked</a>.</p>
<p>You can minimize the space consumption of a group box by enabling the <a href="qgroupbox.html#flat-prop">flat</a> property. In most <a href="qstyle.html">styles</a>, enabling this property results in the removal of the left, right and bottom edges of the frame.</p>
<p>QGroupBox doesn't automatically lay out the child widgets (which are often <a href="qcheckbox.html">QCheckBox</a>es or <a href="qradiobutton.html">QRadioButton</a>s but can be any widgets). The following example shows how we can set up a QGroupBox with a layout:</p>
<pre>     QGroupBox *groupBox = new QGroupBox(tr(&quot;Exclusive Radio Buttons&quot;));

     QRadioButton *radio1 = new QRadioButton(tr(&quot;&amp;Radio button 1&quot;));
     QRadioButton *radio2 = new QRadioButton(tr(&quot;R&amp;adio button 2&quot;));
     QRadioButton *radio3 = new QRadioButton(tr(&quot;Ra&amp;dio button 3&quot;));

     radio1-&gt;setChecked(true);

     QVBoxLayout *vbox = new QVBoxLayout;
     vbox-&gt;addWidget(radio1);
     vbox-&gt;addWidget(radio2);
     vbox-&gt;addWidget(radio3);
     vbox-&gt;addStretch(1);
     groupBox-&gt;setLayout(vbox);</pre>
<p><table width="100%" align="center" cellpadding="2" cellspacing="1" border="0">
<tr valign="top" class="odd"><td><img src="images/windowsxp-groupbox.png" alt="Screenshot of a Windows XP style group box" /></td><td><img src="images/macintosh-groupbox.png" alt="Screenshot of a Macintosh style group box" /></td><td><img src="images/plastique-groupbox.png" alt="Screenshot of a Plastique style group box" /></td></tr>
<tr valign="top" class="even"><td>A <a href="gallery-windowsxp.html">Windows XP style</a> group box.</td><td>A <a href="gallery-macintosh.html">Macintosh style</a> group box.</td><td>A <a href="gallery-plastique.html">Plastique style</a> group box.</td></tr>
</table></p>
<p>See also <a href="qbuttongroup.html">QButtonGroup</a> and <a href="widgets-groupbox.html">Group Box Example</a>.</p>
<hr />
<h2>Property Documentation</h2>
<h3 class="fn"><a name="alignment-prop"></a>alignment : <a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a></h3>
<p>This property holds the alignment of the group box title.</p>
<p>Most styles place the title at the top of the frame. The horizontal alignment of the title can be specified using single values from the following list:</p>
<ul>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignLeft</a> aligns the title text with the left-hand side of the group box.</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignRight</a> aligns the title text with the right-hand side of the group box.</li>
<li><a href="qt.html#AlignmentFlag-enum">Qt::AlignHCenter</a> aligns the title text with the horizontal center of the group box.</li>
</ul>
<p>The default alignment is <a href="qt.html#AlignmentFlag-enum">Qt::AlignLeft</a>.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>Qt::Alignment alignment () const</b></li>
<li><div class="fn"/><b>void setAlignment ( int <i>alignment</i> )</b></li>
</ul>
<p>See also <a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a>.</p>
<h3 class="fn"><a name="checkable-prop"></a>checkable : bool</h3>
<p>This property holds whether the group box has a checkbox in its title.</p>
<p>If this property is true, the group box displays its title using a checkbox in place of an ordinary label. If the checkbox is checked, the group box's children are enabled; otherwise they are disabled and inaccessible.</p>
<p>By default, group boxes are not checkable.</p>
<p>If this property is enabled for a group box, it will also be initially checked to ensure that its contents are enabled.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool isCheckable () const</b></li>
<li><div class="fn"/><b>void setCheckable ( bool <i>checkable</i> )</b></li>
</ul>
<p>See also <a href="qgroupbox.html#checked-prop">checked</a>.</p>
<h3 class="fn"><a name="checked-prop"></a>checked : bool</h3>
<p>This property holds whether the group box is checked.</p>
<p>If the group box is checkable, it is displayed with a check box. If the check box is checked, the group box's children are enabled; otherwise the children are disabled and are inaccessible to the user.</p>
<p>By default, checkable group boxes are also checked.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool isChecked () const</b></li>
<li><div class="fn"/><b>void setChecked ( bool <i>checked</i> )</b></li>
</ul>
<p>See also <a href="qgroupbox.html#checkable-prop">checkable</a>.</p>
<h3 class="fn"><a name="flat-prop"></a>flat : bool</h3>
<p>This property holds whether the group box is painted flat or has a frame.</p>
<p>A group box usually consists of a surrounding frame with a title at the top. If this property is enabled, only the top part of the frame is drawn in most styles; otherwise the whole frame is drawn.</p>
<p>By default, this property is disabled; i.e&#x2e; group boxes are not flat unless explicitly specified.</p>
<p><b>Note:</b> In some styles, flat and non-flat group boxes have similar representations and may not be as distinguishable as they are in other styles.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool isFlat () const</b></li>
<li><div class="fn"/><b>void setFlat ( bool <i>flat</i> )</b></li>
</ul>
<p>See also <a href="qgroupbox.html#title-prop">title</a>.</p>
<h3 class="fn"><a name="title-prop"></a>title : <a href="qstring.html">QString</a></h3>
<p>This property holds the group box title text.</p>
<p>The group box title text will have a keyboard shortcut if the title contains an ampersand ('&amp;') followed by a letter.</p>
<pre> g-&gt;setTitle(&quot;&amp;User information&quot;);</pre>
<p>In the example above, <b>Alt+U</b> moves the keyboard focus to the group box. See the <a href="qshortcut.html#mnemonic">QShortcut</a> documentation for details (to display an actual ampersand, use '&amp;&amp;').</p>
<p>There is no default title text.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QString title () const</b></li>
<li><div class="fn"/><b>void setTitle ( const QString &amp; <i>title</i> )</b></li>
</ul>
<p>See also <a href="qgroupbox.html#alignment-prop">alignment</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QGroupBox"></a>QGroupBox::QGroupBox ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a group box widget with the given <i>parent</i> but with no title.</p>
<h3 class="fn"><a name="QGroupBox-2"></a>QGroupBox::QGroupBox ( const <a href="qstring.html">QString</a> &amp; <i>title</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a group box with the given <i>title</i> and <i>parent</i>.</p>
<h3 class="fn"><a name="dtor.QGroupBox"></a>QGroupBox::~QGroupBox ()</h3>
<p>Destroys the group box.</p>
<h3 class="fn"><a name="clicked"></a>void QGroupBox::clicked ( bool <i>checked</i> = false )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the check box is activated (i.e&#x2e; pressed down then released while the mouse cursor is inside the button), or when the shortcut key is typed, Notably, this signal is <i>not</i> emitted if you call <a href="qgroupbox.html#checked-prop">setChecked</a>().</p>
<p>If the check box is checked <i>checked</i> is true; it is false if the check box is unchecked.</p>
<p>This function was introduced in Qt 4.2.</p>
<p>See also <a href="qgroupbox.html#checkable-prop">checkable</a>, <a href="qgroupbox.html#toggled">toggled</a>(), and <a href="qgroupbox.html#checked-prop">checked</a>.</p>
<h3 class="fn"><a name="initStyleOption"></a>void QGroupBox::initStyleOption ( <a href="qstyleoptiongroupbox.html">QStyleOptionGroupBox</a> * <i>option</i> ) const&nbsp;&nbsp;<tt> [protected]</tt></h3>
<p>Initialize <i>option</i> with the values from this <a href="qgroupbox.html">QGroupBox</a>. This method is useful for subclasses when they need a <a href="qstyleoptiongroupbox.html">QStyleOptionGroupBox</a>, but don't want to fill in all the information themselves.</p>
<p>See also <a href="qstyleoption.html#initFrom">QStyleOption::initFrom</a>().</p>
<h3 class="fn"><a name="toggled"></a>void QGroupBox::toggled ( bool <i>on</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>If the group box is checkable, this signal is emitted when the check box is toggled. <i>on</i> is true if the check box is checked; otherwise it is false.</p>
<p>See also <a href="qgroupbox.html#checkable-prop">checkable</a>.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
